﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InnoWeb.CEND.BL.Service.Page
{
    using InnoWeb.CEND.BL.Infrastructure;
    using InnoWeb.CEND.Core.Model.Page;
    using InnoWeb.CEND.Data;
    using InnoWeb.CEND.Data.Infrastructure;

    public class PageContentService:IService<PageContent>
    {
        private readonly GenericRepository<PageContent> _pageContentRepository;
        private readonly IUnitOfWork _unitOfWork;

        public PageContentService(IUnitOfWork unitOfWork, GenericRepository<PageContent> pageContentRepository)
        {
            this._unitOfWork = unitOfWork;
            this._pageContentRepository = pageContentRepository;
        }

        public IQueryable<PageContent> GetAllElements()
        {
            return _pageContentRepository.GetAll();
        }

        public PageContent GetElementById(int id)
        {
            return _pageContentRepository.GetById(id);
        }

        public void CreateElement(PageContent entity)
        {
            _pageContentRepository.Insert(entity);
        }

        public void UpdateElement(PageContent entity)
        {
            _pageContentRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _pageContentRepository.Delete(id);
        }

        public void SaveChanges()
        {
            this._unitOfWork.SaveChanges();
        }
    }
}
